<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            任务调度系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="./css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
			<form class="layui-form layui-form-pane" onsubmit="return false">
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>任务名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="job_name" name="job_name" value= "test111" class="layui-input" required="" >
                         
                    </div>
					
					<div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入英文任务名称,默认日志按该名称命名
                    </div>
					
                   
                </div>
				
				<div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>任务描述
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="job_desc" name="job_desc" value= "test111" class="layui-input" required=""  >
                        
                    </div>
					
					<div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>任务描述
                    </div>
                   
                </div>
				
				
				<div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">
                            命令类型
                        </label>
                        <div class="layui-input-block" style="width:190px;">
                            <select lay-verify="required" name="cmd_type" id= "cmd_type" >
								<option value="bash">bash</option>
								<option value="php">php</option>
								<option value="python">python</option>
								<option value="curl">curl</option>
                            </select>
                        </div>
                    </div>
                </div>
				
				
				<div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">
                            进程唯一
                        </label>
                        <div class="layui-input-block" style="width:190px;">
                            <select lay-verify="required" name="process_only" id= "process_only" >
								<option value="0">否</option>
								<option value="1">是</option>
								
                            </select>
                        </div>
                    </div>
                </div>
				
				
				
				
				
				
				
				<div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>命令或URL
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="cmd" name="cmd" class="layui-input" value= "b.php" required=""  >
                         
                    </div>
                  
                </div>
				

				
				
				<div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>执行周期
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="job_time" name="job_time" required="" value="* 30 13 * * * * *"
                        autocomplete="off" class="layui-input" >
                    </div>
					
					 <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">1.输入整数,单位：秒;2.按Crontab格式。  如:10或* 15 05 * * * * *</span>
                    </div>
                    
                </div>
				
				
				<div class="layui-form-item">
                    
                <span class="x-red">*</span>周期说明：区别Linux下的Crontab 分 时 天 月 周(* * * * *)。此处的格式为:秒 分 时 天 月 年 周 星期(* * * * * * * *)

                    
                </div>
				
				<div class="layui-form-item">
                    
                <span class="x-red">*</span>取值:秒(0~59),分(0~59),时(0~23),天(1~31),月(1~12),年(4位数字),周(1~53),星期(0~6)

                    
                </div>
				
			
                
                <div class="layui-form-item">
                   
                    <button  class="layui-btn"  onclick="doSubmit()">
                        增加
                    </button>
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<button  class="layui-btn" type="reset">
                        清空
                    </button>
                </div>
            
        </div>
		</form>
        <script src="./lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="./js/x-layui.js" charset="utf-8">
        </script>
        <script>
			layui.use(['form','layer','laydate'], function(){
            $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer
			  ,laydate = layui.laydate;
			  
			  
			  
			
			  

              
            });
			
			
			function doSubmit(){
				job_name = $('#job_name').val();
				job_desc = $('#job_desc').val();
				cmd_type = $('#cmd_type').val();
				cmd = $('#cmd').val();
				job_time = $('#job_time').val();
				process_only = $('#process_only').val();
				
				
				if(job_name == ''||job_desc == ''||cmd == ''||job_time == ''){
				
					layer.alert("缺少参数");
					return false;
				
				}
				
				$.post('/api/checkJob',{job_name:job_name,cmd:cmd,cmd_type:cmd_type},function(res){
					
					if(res.status == 1){
						layer.alert(res.msg, {icon: 6},function () {
							parent.location.reload(); // 父页面刷新
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
						});
						return false;
					}else{
					
					
					
						$.post('/api/addJob',{job_name:job_name,job_desc:job_desc,cmd:cmd,job_time:job_time,cmd_type:cmd_type,process_only:process_only},function(res){
						if(res.status == 0){
							layer.alert("增加成功", {icon: 6},function () {
								parent.location.reload(); // 父页面刷新
								var index = parent.layer.getFrameIndex(window.name);
								parent.layer.close(index);
							});
							return false;
						}
					
						},"json");

					}
					
				},"json");
				
				
				
				
				

			}
			
			
			
			
			
            
        </script>
        
    </body>

</html>